<template>
  <div class="app-container">
    <el-card>
      <!--工具栏-->
      <div class="head-container">
        <!--<eHeader :permission="permission"/>-->
        <crudOperation :permission="permission" />
      </div>
      <!--工具栏-->

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="name" label="公司" />
        <el-table-column prop="city" label="地址" />
        <el-table-column prop="img" label="公司logo" >
          <template slot-scope="scope">
            <el-image :src="baseApi + '/recruit/' + scope.row.img"></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="mission" label="使命" />
        <el-table-column prop="foreignName" label="英文名" />
        <el-table-column  label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </el-card>


  </div>
</template>

<script>
  import checkPermission from '@/utils/permission'
  import crudInterest from '@/api/ceamInterest'
  import eHeader from './header'
  import CRUD, { presenter} from '@crud/crud'
  import crudOperation from '@crud/CRUD.operation'
  import pagination from '@crud/Pagination'
  import udOperation from '@crud/UD.operation'
  import { mapGetters } from 'vuex'
  import { getToken } from '@/utils/auth'

  // crud交由presenter持有
  const crud = CRUD({
    title: '关注企业',
    url: 'api/interest',
    sort: ['sort,asc', 'id,desc'],
    crudMethod: { ...crudInterest }
  })

  export default {
    components: { eHeader, crudOperation, pagination, udOperation },
    mixins: [presenter(crud),],
    data() {
      return {
        headers: {
          'Authorization': getToken()
        },
        delLoading: false,
        permission: {
          add: ['admin', 'notice:add'],
          edit: ['admin', 'notice:edit'],
          del: ['admin', 'interest:del']
        }
      }
    },
    computed: {
      ...mapGetters([
        'uploadImgApi',
        'baseApi'
      ])
    },
    created() {
      this.$nextTick(() => {
        //this.init()
      })
    },
    methods: {
      checkPermission

    }
  }
</script>

<style scoped>

</style>
